﻿using System;

namespace _46.Action和Func
{
    class Program
    {
        public delegate void MeDe();
        public delegate int MeD();
        static void Main(string[] args)
        {
            //Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action Action
            //Action 默认指向没有返回值没有参数的方法，可以写多个参数但是没有返回值。
            //Action a = new Action(b);
            //a();
            //Action<int> a1 = new Action<int>(b);
            //a1(10);
            //MeDe c = new MeDe(b);
            //c();
            //Action<int, string> a2 = new Action<int, string>(b);
            //a2(100, "小小");

            //Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func Func 
            //有返回值的委托。里面的参数最后一个是返回值类型
            //里面的参数是16位
            //注册方法
            Func<int> a = new Func<int>(c);
            Func<int> a11 = c;
            int b = a11();
            Console.WriteLine(b);
            Func<int, bool, string> f = new Func<int, bool, string>(D);
            string a2= f(100, true);
            Console.WriteLine(a2);

        }
        public static void b()
        {
            Console.WriteLine("莱迪");
        }
        public static void b(int a)
        {
            Console.WriteLine("------" + a);
        }
        public static void b(int a, string b)
        {
            Console.WriteLine(b + "------" + a);
        }
        public static int c()
        {
            return 10;
        }
        public static string D(int a,bool b)
        {
            return "耀" + a + b;
        }
    }
}
   
